#ifndef ALTTILESETGRAPHICSITEM_H
#define ALTTILESETGRAPHICSITEM_H

#include <QGraphicsItem>

namespace Alt {
     class Tileset;

     /*! Graphics item for previewing tilesets. */
     class TilesetGraphicsItem : public QObject, public QGraphicsItem {
          Q_OBJECT
     public:
          /*! Constructor.
               \param tileset The tileset to preview.
               \param parent The parent item. */
          TilesetGraphicsItem(const Tileset* tileset, QGraphicsItem* parent = 0);

          QRectF boundingRect() const;

          void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);

          /*! Sets the tileset being previewed.
               \param tileset The new tileset to preview. */
          void setTileset(const Tileset* tileset);

          /*! The tileset being previewed. */
          const Tileset* tileset() const;

     public slots:
          /*! Triggers a repaint whenever the tileset is updated. */
          void update();

     signals:
          /*! Emitted when a tile is clicked.
               \param tileNumber The number of the clicked tile. */
          void tileClicked(int tileNumber);

     private:
          void mousePressEvent(QGraphicsSceneMouseEvent* event);

          void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);

          /*! The tileset being previewed. */
          const Tileset* m_tileset;
     };
}

#endif
